﻿Imports Telerik.Web.UI
Imports System.Globalization
Imports System.Threading

Partial Class Lookup
    Inherits System.Web.UI.Page

    Dim _CommandName As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim _lblPageTitle As Label
            _lblPageTitle = Me.Master.FindControl("lblPageTitle")
            _lblPageTitle.Text = GetLocalResourceObject("PageTitle")
        End If
    End Sub

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Me.Theme = GetGlobalResourceObject("SystemResource", "Theme")
    End Sub

    Protected Sub rgActivities_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgLookup.ItemCommand
        _CommandName = e.CommandName
    End Sub

    Protected Sub rgActivities_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgLookup.ItemDataBound

        If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) And _CommandName <> "InitInsert" Then

            Dim editFormItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
            Dim parentItem As GridDataItem = editFormItem.ParentItem

            Dim box As RadComboBox = CType(editFormItem.FindControl("rcbOrderID"), RadComboBox)
            box.SelectedValue = parentItem("OrderID").Text

        End If
        
    End Sub


    Protected Sub rgLookup_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgLookup.PreRender
        'If Not (Request.Cookies("Language") Is Nothing) AndAlso Not (Request.Cookies("Language").Value Is Nothing) Then
        '    For Each column As GridColumn In rgLookup.Columns
        '        If (Request.Cookies("Language").Value = "ar-JO") Then
        '            If TypeOf column Is GridColumn Then
        '                If column.UniqueName = "DescriptionEn" Then
        '                    CType(column, GridBoundColumn).Visible = False
        '                ElseIf column.UniqueName = "DescriptionAR" Then
        '                    CType(column, GridBoundColumn).Visible = True
        '                End If
        '            End If
        '        Else
        '            If TypeOf column Is GridColumn Then
        '                If column.UniqueName = "DescriptionEn" Then
        '                    CType(column, GridBoundColumn).Visible = True
        '                ElseIf column.UniqueName = "DescriptionAR" Then
        '                    CType(column, GridBoundColumn).Visible = False
        '                End If
        '            End If
        '        End If
        '    Next
        'End If
    End Sub

    'Protected Sub SetCulture(ByVal name As String, ByVal locale As String)
    '    Thread.CurrentThread.CurrentUICulture = New CultureInfo(name)
    '    Thread.CurrentThread.CurrentCulture = New CultureInfo(locale)
    '    Session(UIConstants.UI_CULTURE) = Thread.CurrentThread.CurrentUICulture
    '    Session(UIConstants.CULTURE) = Thread.CurrentThread.CurrentCulture
    'End Sub

End Class
